User   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
rs 10
c 0
b 0
f 0
ccs 3
cts 5
cp 0.6
wmc 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A constructor 0 3 1
A updatePassword 0 4 1
A add 0 4 1
1
/**
2
 * User model
3
 *
4
 * @since 1.0.0
5
 */
6
7 4
const Model = require('./Model');
8 4
const authUtil = require('../common/auth-util');
9
10
class User extends Model {
11
  constructor() {
12 4
    super('user', [{ key: { username: 1 } }]);
13
  }
14
15
  add(user) {
16 1
    const encryptPassword = authUtil.encryptPassword(user);
17 1
    return super.add(Object.assign({}, user, { password: encryptPassword }));
18
  }
19
20
  updatePassword(username, newPassword) {
21
    const encryptPassword = authUtil.encryptPassword({ username, password: newPassword });
22
    return super.updateWithQuery({ username }, { password: encryptPassword, isTemporary: false });
23
  }
24
}
25
26
module.exports = new User();
27